
    // //配置持久化操作vuex-persist
    // import VuexPersistence from 'vuex-persist'
 
    // //创建对象配置持久化
    // const vuexLocal = new VuexPersistence({
    //     //定义本地存储的方式，sessionStorage或localStorage
    //     storage: window.localStorage
    // })
    // //配置插件支持
    // plugins: [vuexLocal.plugin]


const state = {
  // 当前打开的标签页面
  openTabs: [{
    path: '/',
    name: '首页'
  }],
  //激活状态
  activeIndexTab: '/'
}
const getters = {}
const mutations = {
  setActiveTab(state, data) {
    state.activeIndexTab = data
  },
  addTab(state, data) {
    state.openTabs.push(data)
    this.commit('openTabs/setActiveTab', data.path)
  },
  deleteOpenTab(state, data) {
    state.openTabs.forEach((element, index) => {
      if (element.path === data) {
        state.openTabs.splice(index, 1)
      }
    })
  },
  refreshOpenTabs(state, data) {
    state.openTabs = data
  },
  // 关闭当前
  closeSelectedTab(state, data) {
    console.log('closeSelected', data, state.openTabs)
    state.openTabs = state.openTabs.filter(tab => {
      return tab.name !== data
    })
    this.commit('openTabs/refreshOpenTabs', state.openTabs)
    this.commit('openTabs/setActiveTab', state.openTabs[state.openTabs.length - 1].path)
  },
  // 关闭其他
  closeOtherTabs(state, data) {
    state.openTabs = state.openTabs.filter(tab => {
      return tab.name === data || tab.name === '首页'
    })
    this.commit('openTabs/refreshOpenTabs', state.openTabs)
    this.commit('openTabs/setActiveTab', state.openTabs[state.openTabs.length - 1].path)
  },
  // 关闭所有
  closeAllTabs(state, data) {
    state.openTabs = [{
      path: '/',
      name: '首页'
    }]
    this.commit('openTabs/refreshOpenTabs', state.openTabs)
    this.commit('openTabs/setActiveTab', '/')
  }
}
const actions = {}

export default {
  namespaced: true, // 为模块添加命名空间, 推荐使用
  state,
  getters,
  mutations,
  actions
}